{% extends 'posts.html' %}
{% block content %}
  <div class="layui-col-md8">
    <div class="fly-panel" style="margin-bottom: 0;">
      <form action="{% url 'search' %}" method="get" class="layui-form"
            style="text-align: center; padding-top: 30px">
        <div class="layui-form-item">
          <div class="layui-inline">
            <input type="text" name="kw" class="layui-input layui-input-inline" value="{{ kw }}" placeholder="请输入搜索关键字"
                   >
          </div>
          <div class="layui-inline">
            <button class="layui-btn">搜索</button>
          </div>
        </div>

      </form>
      {% if kw %}
        <p style="margin: 8px;">"{{ kw }}"的搜索结果共有 <span style="color:red;">{{ total }}{# TODO #}</span> 条</p>
      {% endif %}

      <ul class="fly-list">
        {% for item in page_data %}{# TODO #}
          <li>
            <a href="{% url 'user_home_other' item.creator.pk %}" class="fly-avatar">
              <img src="{{ item.creator.avatar.url }}" alt="{{ item.creator.user.username }}">
            </a>
            <h2>
              <a class="layui-badge">{{ item.catalog.name }}</a>
              <a href="{% url 'post_detail' item.pk %}">{{ item.title }}</a>
            </h2>
            <div class="fly-list-info">
              <a href="{% url 'user_home_other' item.creator.pk %}" link>
                <cite>{{ item.creator.user.username|default:'无名' }}</cite>
                {% if item.creator.renzheng %}
                  <i class="iconfont icon-renzheng">{{ item.creator.renzheng }}</i>
                {% endif %}
                {% if item.creator.vip|default:0 > 0 %}
                  <i class="layui-badge fly-badge-vip">VIP{{ item.creator.vip }}</i>
                {% endif %}
              </a>
              <span>{{ item.create_at|date:'Y-m-d H:i' }}</span>

            </div>
          </li>
        {% empty %}
          <div style="min-height: 60px; text-align: center; padding-top:50px; color: #999;">{{ message|default:'没有相关数据' }}</div>
        {% endfor %}
      </ul>
        {% if page_range|length > 1 %}
          {% with queryset=page_data %}
            {% include 'paginator_nav.html' %}
          {% endwith %}
        {% endif %}
    </div>
  </div>
{% endblock %}